use std::sync::{Arc, Mutex};
use std::thread;

fn main() {
    let counter = Arc::new(Mutex::new(5));
    let mut handlers = vec![];
    for _i in 0..10 {
        let arc = counter.clone();
        let h = thread::spawn(move || {
            let mut num = arc.lock().unwrap();
            *num += 1;
            println!("{}", *num);
        });
        handlers.push(h);
    }

    for x in handlers {
        x.join().unwrap();
    }
}
